package com.yenlien.traceyun.plant.dao;

import com.yenlien.traceyun.plant.entity.FarmType;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface FarmTypeDao extends BaseJpaDao<FarmType> {


    List<FarmType> getByState(String state);

    @Transactional
    @Modifying
    @Query(value = "UPDATE t_plant_farm_type SET state = ?1 WHERE id IN (?2)", nativeQuery = true)
    Integer updateState(String state, List<String> idList);




    @Query(value = "SELECT id FROM t_plant_farm_type WHERE type = ?1", nativeQuery = true)
    String checkByType(String type);


    @Query(value = "SELECT * FROM t_plant_farm_type WHERE type = ?1", nativeQuery = true)
    FarmType getByType(String type);

}
